global class TestBatchSOQLIssue implements Database.Batchable<sObject> {

	final String query = 'Select Id, Name, IM_Enterprise_Account_Manager__c, IM_Enterprise_Account_Manager_FORMULA__c, ' + 
							'Parent.IM_Hierarchy_Level__c, ' +	
							'Parent.IM_Enterprise_Account_Manager__c, ' +
							'Parent.Parent.IM_Enterprise_Account_Manager__c, ' +
							'Parent.Parent.Parent.IM_Enterprise_Account_Manager__c, ' +
							'Parent.Parent.Parent.Parent.IM_Enterprise_Account_Manager__c, ' +
							'Parent.Parent.Parent.Parent.Parent.IM_Enterprise_Account_Manager__c ' +
						  'From Account where IM_Hierarchy_Level__c != \'Book of Business/IMGA\' AND Name LIKE \'%BATCH SOQL TEST%\'';
	
	global Database.QueryLocator start(Database.BatchableContext BC){
		System.debug('============== inside start method - do nothing ========================');
    	return Database.getQueryLocator(query);
	}


	global void execute(Database.BatchableContext BC, List<sObject> scope){
		System.debug('============== inside execute method ========================');
	
		String fromFieldValue = null;
		
		/*
		for(sObject sObj : scope){
			fromFieldValue = String.valueOf(sObj.get('IM_Enterprise_Account_Manager_FORMULA__c'));
			
			System.debug('-------------- sObject: ' + sObj);
			System.debug('-------------- IM_Enterprise_Account_Manager_FORMULA__c: ' + fromFieldValue);
		}
		*/
		
		sObject sObj;
		sObject sObjNext;
		for(Integer i=0; i<scope.size()-1; i++){
			
			sObj = scope[i];
			sObjNext = scope[i+1];
			
			fromFieldValue = String.valueOf(sObjNext.get('IM_Enterprise_Account_Manager_FORMULA__c'));
			
			System.debug('-------------- sObject: ' + sObj);
			System.debug('-------------- IM_Enterprise_Account_Manager_FORMULA__c: ' + fromFieldValue);
		}
		
	}

	global void finish(Database.BatchableContext BC){
		System.debug('============== inside finish method - do nothing ========================');
	}
}